import { menulist } from '../../../request/api';

// 封装一个接口类型
interface StateMenu {
    menuList: Array<object>
}

const state = {
    menuList: []
}

const mutations = {
    MENU_LIST(state:StateMenu,payload:any){
        state.menuList = payload
    }
}

const actions = {
    getMenulistActions(context: any) {
        menulist({
            istree: true
        }).then((res:any) => {
            // console.log(res);            
            context.commit('MENU_LIST',res.list)
        })
    }
}

const getters = {
    // 将menuList反出去
    getMenuList(state: StateMenu) {
        return state.menuList
    }
}

export default {
    state,
    mutations,
    actions,
    getters,
    namespaced: true
}